class Solution(object):
    def minimumBuckets(self, street):
        last = -1
        index = 0
        n = len(street)
        ans = 0
        while index < n:
            if street[index] == 'H':
                if index == 0:
                    if index + 1 < n and street[index + 1] == '.':
                        ans += 1
                        last = index + 1
                        index += 2
                    else:
                        print(1)
                        return -1
                else:
                    if street[index - 1] == '.':
                        if last == index - 1:
                            index += 1
                        else:
                            if index + 1 < n and street[index + 1] == '.':
                                ans += 1
                                last = index + 1
                                index += 2
                            else:
                                ans += 1
                                last = index - 1
                                index += 1
                    else:
                        if index + 1 < n and street[index + 1] == '.':
                            ans += 1
                            last = index + 1
                            index += 2
                        else:
                            return -1
            else:
                index += 1
        return ans


data = Solution()
street = 'H..H'
print(data.minimumBuckets(street))
